import { ApiResult } from './index';

enum Api {
	HomeData = '/Api/MF_ManagerFront/MF_Home/PostHome',
	CommonFunctions = '/Api/MF_ManagerFront/MF_Home/CommonFunctions',
	AddCommonFunctions = '/Api/MF_ManagerFront/MF_Home/PostCommonFunctions_Insert',
	UpdatePassword = '/Api/MF_ManagerFront/MF_Home/PostUpdatePassword',
	PostRedDot = '/Api/MF_ManagerFront/MF_Home/PostRedDotPrompt',
	
	// 请求前往积分商城URL
	PostLoadUrl = '/Api/MF_ManagerFront/MF_NewMall_Order/PostLoadUrl',
	
	// 权限查询
	PostPermissionQuery = '/Api/MF_ManagerFront/MF_Home/PostPermissionQuery',
}

export interface HomeDataModel extends ApiResult {
	PhotoList: {
		Key: string,
		Value: string,
		Value_T: string
	}[],
	FirstDealerCount: number
	DoubleDealerCount: number
	DoorDealerCount: number
}


export function useHomeApi(vm: any) {
	
	const getHomeData = (params: {}): HomeDataModel => {
		return vm.$u.post(Api.HomeData, params)
	}
	
	const getCommonFunctions = (params: {}) => {
		return vm.$u.post(Api.CommonFunctions, params)
	}
	
	const addCommonFunctions = (params: {}) => {
		return vm.$u.post(Api.AddCommonFunctions, params)
	}
	
	const updatePassword = (params: {}) => {
		return vm.$u.post(Api.UpdatePassword, params)
	}
	
	const getRedDotCount = (params: {}) => {
		return vm.$u.post(Api.PostRedDot, params)
	}
	
	const getLoadUrl = (params: {}) => {
		return vm.$u.post(Api.PostLoadUrl, params)
	}
	
	const permissionQuery = (params: {}) => {
		return vm.$u.post(Api.PostPermissionQuery, params)
	}

	return {
		getHomeData,
		getCommonFunctions,
		addCommonFunctions,
		updatePassword,
		getRedDotCount,
		getLoadUrl,
		permissionQuery
	}
	
}